package fybug.nulll.pdstream.WR.Parsing;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.Reader;

import static fybug.nulll.pdstream.WR.Parsing.Source.ParsingSourceS.creatLineSoure;
import static fybug.nulll.pdstream.WR.Parsing.Source.ParsingSourceS.creatSoure;
import static fybug.nulll.pdstream.WR.Parsing.Source.ParsingSourceS.creatTableSoure;
/**
 * <h2>解析器构造工场.</h2>
 * <pre>
 * 用于构造 <b>文本解析器</b>
 *
 * 包含:
 * {@link #creatLineParsing(CharSequence)} 行解析器
 * {@link #creatTableParsing(CharSequence)} 表单解析器
 * </pre>
 *
 * @author fybug
 * @version 0.0.4
 * @see StringParsingBoot
 * @since JDK 1.8
 */
@SuppressWarnings( "all" )
public final
class StringParsingS {
    /** {@Hide} */
    @Deprecated
    private
    StringParsingS() {}

    /*
     * MainParsing
     */

    /**
     * <p>根据 <b>传入的字符串</b> 和 <b>分隔符</b> 构建解析器.</p>
     *
     * @param charSequence 要解析的字符串
     * @param parsing      分隔符
     */
    @NotNull
    public static
    StringParsingBoot creatParsing(@NotNull final CharSequence charSequence,
            @Nullable final CharSequence... parsing)
    { return new StringParsing(creatSoure(charSequence, parsing)); }

    /** <p>根据 <b>传入的字节流</b> 和 <b>分隔符</b> 构建解析器.</p> */
    @NotNull
    public static
    StringParsingBoot creatParsing(@NotNull final InputStream charSequence,
            @Nullable final CharSequence... parsing)
    { return new StringParsing(creatSoure(charSequence, parsing)); }

    /** <p>根据 <b>传入的字符流</b> 和 <b>分隔符</b> 构建解析器.</p> */
    @NotNull
    public static
    StringParsingBoot creatParsing(@NotNull final Reader charSequence,
            @Nullable final CharSequence... parsing)
    { return new StringParsing(creatSoure(charSequence, parsing)); }

    /** <p>根据 <b>分隔符</b> 构建文本文件解析器.</p> */
    @NotNull
    public static
    StringParsingBoot creatParsing(@NotNull final File charSequence,
            @Nullable final CharSequence... parsing) throws FileNotFoundException
    { return new StringParsing(creatSoure(new FileInputStream(charSequence), parsing)); }

    /*
     * LineParsing
     */

    /** <p>根据 <b>传入的字符串</b> 构建行解析器.</p> */
    @NotNull
    public static
    StringParsingBoot creatLineParsing(@NotNull final CharSequence charSequence)
    { return new StringParsing(creatLineSoure(charSequence)); }

    /** <p>根据 <b>传入的字节流</b> 构建行解析器.</p> */
    @NotNull
    public static
    StringParsingBoot creatLineParsing(@NotNull final InputStream charSequence)
    { return new StringParsing(creatLineSoure(charSequence)); }

    /** <p>根据 <b>传入的字符流</b> 构建行解析器.</p> */
    @NotNull
    public static
    StringParsingBoot creatLineParsing(@NotNull final Reader charSequence)
    { return new StringParsing(creatLineSoure(charSequence)); }

    /** <p>构建逐行解析文本文件的解析器.</p> */
    @NotNull
    public static
    StringParsingBoot creatLineParsing(@NotNull final File charSequence)
    throws FileNotFoundException
    { return new StringParsing(creatLineSoure(new FileInputStream(charSequence))); }

    /*
     * TableParsing
     */

    /** <p>根据 <b>传入的字符串</b> 构建表单解析器.</p> */
    @NotNull
    public static
    StringParsingBoot creatTableParsing(@NotNull final CharSequence charSequence)
    { return new StringParsing(creatTableSoure(charSequence)); }

    /** <p>根据 <b>传入的字节流</b> 构建表单解析器.</p> */
    @NotNull
    public static
    StringParsingBoot creatTableParsing(@NotNull final InputStream charSequence)
    { return new StringParsing(creatTableSoure(charSequence)); }

    /** <p>根据 <b>传入的字符流</b> 构建表单解析器.</p> */
    @NotNull
    public static
    StringParsingBoot creatTableParsing(@NotNull final Reader charSequence)
    { return new StringParsing(creatTableSoure(charSequence)); }
}
